<?php
namespace Home\Controller;

use Think\Controller;
class LoginController extends Controller {
   public function index() {
       if(session('admin')) {
           $this->redirect('Index/index');
       } else {
           $this->display();
       }
   }


   //验证登录
    public function checkUser() {
       if (IS_AJAX) {
            $User = D('User');
           echo $User->checkUser(I('post.accounts'),I('post.password'));
       } else {
           $this->error('非法操作');
       }
    }

    //前台login 新增业务帐号 操作
    public function UserRegister() {
        if(IS_AJAX) {
            $User = D('User');
            echo $User->register(
                I('post.accounts'),
                I('post.password'),
                I('post.staff_id'),
                I('post.staff_name'),
                I('post.notpassword'),
                I('post.state'),
                I('post.tel'),
                I('post.not')
            );
        } else {
            $this->error('非法操作');
        }
    }
    //后台退出登录
    public function logout() {
        session('admin',null);
        $this->redirect('Login/index');
    }
}